import type { Ref } from 'vue'
import type { VxePagerDefines } from 'vxe-table'

import type { SearchParams } from '../types'

type Params = {
  searchParams: Ref<SearchParams>
  handleGetVideoList: PromiseFunc
}

export function usePager({ searchParams, handleGetVideoList }: Params) {
  function handlePageChange(value: VxePagerDefines.PageChangeEventParams) {
    searchParams.value.pageParameter.currentPage = value.currentPage
    searchParams.value.pageParameter.pageSize = value.pageSize
    handleGetVideoList()
  }

  return {
    handlePageChange
  }
}
